<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>toISOString() | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>toISOString()</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>toISOString()</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/displaying/as-iso-string/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/04-displaying/14-as-iso-string.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().toISOString();
moment().toISOString(keepOffset); // &#x4ECE; 2.20.0 &#x5F00;&#x59CB;
</code></pre>

							</div>
<p>&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x683C;&#x5F0F;&#x5316;&#x4E3A; ISO8601 &#x6807;&#x51C6;&#x3002;</p>
<pre><code class="language-javascript">moment().toISOString() // 2013-02-04T22:44:30.652Z
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x5373;&#x4F7F;&#x95EE;&#x9898;&#x4E2D;&#x7684; moment &#x5904;&#x4E8E;&#x672C;&#x5730;&#x6A21;&#x5F0F;&#xFF0C;<code>.toISOString()</code> &#x4E5F;&#x4F1A;&#x4EE5; UTC &#x8FD4;&#x56DE;&#x65F6;&#x95F4;&#x6233;&#x3002;
&#x8FD9;&#x6837;&#x505A;&#x662F;&#x4E3A;&#x4E86;&#x4E0E; <a href="javascript:window.open('http://nodejs.cn/s/kLpcLz');" target="_blank" rel="nofollow">ES2015 &#x89C4;&#x8303;</a>&#x4E2D;&#x6982;&#x8FF0;&#x7684;&#x539F;&#x751F; JavaScript Date <code>.toISOString()</code> &#x89C4;&#x8303;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#x3002;
&#x4ECE; <strong>2.20.0</strong> &#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;&#x53EF;&#x4EE5;&#x8C03;&#x7528; <code>.toISOString(true)</code> &#x4EE5;&#x9632;&#x6B62; UTC &#x8F6C;&#x6362;&#x3002;</p>
<p>&#x4ECE; <strong>2.8.4</strong> &#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;&#x51FA;&#x4E8E;&#x6027;&#x80FD;&#x539F;&#x56E0;&#xFF0C;&#x5C3D;&#x53EF;&#x80FD;&#x4F7F;&#x7528;&#x539F;&#x751F; <code>Date.prototype.toISOString</code>&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().toISOString();
moment().toISOString(keepOffset); // from 2.20.0
</code></pre>

							</div>
<p>Formats a string to the ISO8601 standard.</p>
<pre><code class="language-javascript">moment().toISOString() // 2013-02-04T22:44:30.652Z
</code></pre>
<p>Note that <code>.toISOString()</code> returns a timestamp in UTC, even if the moment in question is in local mode. This is done to provide consistency with the specification for native JavaScript Date <code>.toISOString()</code>, as outlined in
<a href="javascript:window.open('https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.toisostring');" target="_blank" rel="nofollow"> the ES2015 specification</a>. From version <strong>2.20.0</strong>, you may call <code>.toISOString(true)</code> to prevent UTC conversion.</p>
<p>From version <strong>2.8.4</strong> the native <code>Date.prototype.toISOString</code> is used if
available, for performance reasons.</p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>